﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity;
using DAL;

namespace BLL
{
    public class LocalService
    {
        LocalDAL localDAL = new LocalDAL();
        public void CreateLocal(BoLocal local)
        {
            localDAL.Insert(local);           
        }

        public void UpdateLocal(BoLocal local)
        {
            localDAL.Update(local);            
        }

        public void DeleteLocal(BoLocal local)
        {
            if (new DbCommon.DbHelper().GetCount("Academy", "ACA_LOCAL='" + local.LOC_ID + "'and ACA_IsShow='true'") > 0)
            {
                System.Windows.Forms.MessageBox.Show("该校区下还有学院，请先删除学院，再删除校区!");
            }
            else
            {
                localDAL.Delete(local.LOC_ID);
            }
        }
        //public void DeleteLocal(BoLocal local)
        //{
        //    localDAL.Delete(local.LOC_ID);
        //    new BLL.AcademyService().DeleteAcademyByLocalId(local.LOC_ID);
        //}

        public BoLocal getLocal(string id)
        {
            return localDAL.GetModel(id);
        }

        public List<BoLocal> getAllLocal()
        {
            return localDAL.GetLocal();
        }

        /// <summary>
        /// 通过校区名字来获得校区对象
        /// </summary>
        /// <param name="LocalName">校区的名字</param>
        /// <returns>返回校区对象</returns>
        public BoLocal GetLocalByName(string LocalName)
        {
            return localDAL.GetLocalByName(LocalName.Trim());
        }
        
    }
}
